﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using FactoryAuto.Device;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("DLL版本：{0}", CH341.GetVersion());
            var ch341 = new CH341();
            
            var ret = ch341.OpenDevice();
            if (ret != 0)
            {
                Console.WriteLine("CH341打开失败");
                Console.ReadKey();
                return;
            }
            Console.WriteLine("CH341打开成功");

            Console.WriteLine("你可以用万用表测试CH341的GPIO_D5_D0电压的高低");
            ret = ch341.Set_D5_D0_Low();
            if (ret != 0)
            {
                Console.WriteLine("CH341_D5_D0低电平失败");
                Console.ReadKey();
                return;
            }
            Console.WriteLine("CH341_D5_D0低电平成功");
        
            Console.WriteLine("请按任意键切换电平");
            Console.ReadKey();
            ret = ch341.Set_D5_D0_High();
            if (ret != 0)
            {
                Console.WriteLine("CH341_D5_D0高电平失败");
                Console.ReadKey();
                return;
            }
            Console.WriteLine("CH341_D5_D0高电平成功");

            Console.WriteLine("请按任意键切换电平");
            Console.ReadKey();
            ret = ch341.Set_D5_D0_Low();
            if (ret != 0)
            {
                Console.WriteLine("CH341_D5_D0低电平失败");
                Console.ReadKey();
                return;
            }
            Console.WriteLine("CH341_D5_D0低电平成功");

            Console.WriteLine("请按任意键切换电平");
            Console.ReadKey();
            ret = ch341.Set_D5_D0_High();

            if (ret != 0)
            {
                Console.WriteLine("CH341_D5_D0高电平失败");
                Console.ReadKey();
                return;
            }
            Console.WriteLine("CH341_D5_D0高电平成功");
          
            Console.WriteLine("请按任意键结束测试");
            Console.ReadKey();
            ch341.CloseDevice();
            Console.WriteLine("CH341关闭");

            Console.WriteLine("请按任意键退出程序");
            Console.ReadKey();
        }
    }
}
